package com.atguigu.flink.chapter05.Source;

import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.connector.kafka.source.KafkaSource;
import org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
import org.apache.kafka.clients.consumer.ConsumerConfig;

import java.util.Properties;

/**
 * TODO 读文件
 *
 * @author cjp
 * @version 1.0
 * @date 2021/8/7 16:31
 */
public class Flink04_Kafka_new {
    public static void main(String[] args) throws Exception {
        // 0. 执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);


/*        KafkaSource<String> kafkaSource = KafkaSource.<String>builder()
                .setBootstrapServers("hadoop1:9092")    // 必需
                .setTopics("flink210323")               // 必需
                .setGroupId("ahahha")                   // 必需
                .setValueOnlyDeserializer(new SimpleStringSchema())  // 必需
                .setStartingOffsets(OffsetsInitializer.earliest())
                .build();

        env
                .fromSource(kafkaSource, WatermarkStrategy.noWatermarks(), "wuyanzu")
                .print();*/


        env.execute();


    }
}
